/**
 * Created by thinkpad on 2017-06-06.
 */
XBox.define("kendo.window",
{
    title: "Window",
    templates: {
        main: [
            "<div style='height:800px;'>" +
            "<span class='window'>窗口</span>" +
            "</div>"
        ],
    },
    elements: {
        window: "span.window",
    },
    events: {
        window: function () {
            var wnd = new XBox.window({
                title: "我就是个窗口",
                autoOpen:true,
                destroyWhenClose: true,
                init: function () {
                    this.form = new XBox.form({
                        container: this.container,
                        action: "append",
                        itemClass: "form-item",
                        items: {
                            KendoDate: {
                                text: "Kendo日期", type: "kendo-date",
                                options: { format: "yyyy-MM-dd" }
                            },
                            KendoDateTime: {
                                text: "Kendo时间", type: "kendo-datetime",
                                options: { format: "yyyy-MM-dd HH:mm:ss" }
                            },
                            KendoAutoComplete: {
                                text: "自动填充", type: "autoComplete",
                                options: { dataSource: { data: ["One", "Two"] } }
                            },
                            KendoSelect: {
                                text: "下拉框", type: "kendo-comboBox",
                                options: { dataSource: { data: ["One", "Two"] } }
                            },
                            KendoDropDownList: {
                                text: "只读下拉框", type: "kendo-dropDownList",
                                options: { dataSource: { data: ["One", "Two"] } }
                            },
                            KendoNumber: {
                                text: "数字", type: "kendo-number",
                                validation: { min: 5, max: 10 },
                                options: { max: 100, min: 0, spinners: false, format: "0.00" }
                            }
                        },
                        data: {
                            KendoDate: new Date(2017, 5, 12),
                            KendoDateTime: new Date(),
                        }
                    });
                },
                buttons: [{
                    text: "取消",
                    name: "btnCancel",
                    theme: "",//"k-primary",
                    handler: "cancel"//名称或函数
                },
                {
                    text: "确定",
                    name: "btnOk",
                    theme: "k-primary",//"k-primary",
                    handler: "ok"//名称或函数
                }],
                ok: function () {
                    if (this.form && this.form.validAll()) {
                        var data = this.form.getValues();
                        console.log(data);
                    } else {
                        var error = this.form.errors;
                        console.log(error);
                    }
                },
                cancel: function () {
                    this.close();
                }
            });
        }
    }
});
